Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct bug with repeated substation in TransformGrid._add_bus #384

Merged
merged 2 commits into from
Jan 29, 2021

Conversation

danielolsen
Copy link
Contributor

Purpose

Fix an Exception that's thrown when you add two new buses with the same coordinates.

What the code is doing

In TransformGrid the latlon2sub variable holds a dictionary of {(lat, lon): list_of_substation_ids}. When we add a bus at a new location, we create a new substation, and we want to add its id to this lookup dict, but we had been adding it as an int, rather than a list containing that int.

test_transform_grid is updated to check for this bug.

Testing

The unit test is updated to check for this bug, and after the fix all tests pass again.

Time estimate

2 minutes.

Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@danielolsen
Copy link
Contributor Author

Good catch!

I caught it the hard way 😩

@rouille
Copy link
Collaborator

rouille commented Jan 29, 2021

Where is the Exception raised when you add two buses at the same location?

@danielolsen
Copy link
Contributor Author

Where is the Exception raised when you add two buses at the same location?

sub_id = latlon2sub[(lat, lon)][0] within TransformGrid._add_bus. We get IndexError: invalid index to scalar variable. when we try to add the second new bus, since we try to [0] into an int.

@danielolsen danielolsen merged commit 94793ee into develop Jan 29, 2021
@danielolsen danielolsen deleted the daniel/add_bus_bug branch January 29, 2021 16:51
@ahurli ahurli mentioned this pull request Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants